libxl: when using pygrub, do not segfault if no blktap
authorStefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Fri, 28 Jan 2011 16:54:13 +0000 (16:54 +0000)
committerStefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Fri, 28 Jan 2011 16:54:13 +0000 (16:54 +0000)
commit3146a8a802232659e3264c6b67b0c4195b8c237e
tree3379534dc65a4c83122365ab3939c0ad33f640ec
parenta76377f10e9df051a820c55ab83ed9fffa7e9a53
libxl: when using pygrub, do not segfault if no blktap

Running xl create configfile where configfile includes the lines
   bootloader = "/usr/bin/pygrub"
   disk = [ 'file:/dev/mapper/vg0-partname,xvda1,w' ]
then xl segfaults at the line
     ret = strdup(dev);
of libxl_device_disk_local_attach() in tools/libxl/libxl.c . The
problem is that dev is not set if libxl__blktap_enabled(&gc) is false
or if phystype isn't recognized.  In the latter case we want to skip
that line and return NULL, but if libxl__blktap_enabled(&gc) is false
we should be returning something, at least in the cases where the
device has a name in the host which we can just refer to.

Also improve the error message when QCOW or QCOW2 are specified, and
avoid using an uninitialised value of "ret".

Signed-off-by: M A Young <m.a.young@durham.ac.uk>
Signed-off-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c